package com.platform.system.controller;

import com.platform.common.annotations.ResponseResult;
import com.platform.common.bean.BaseException;
import com.platform.common.controller.BaseController;
import com.platform.common.menus.ResultCodeEnum;
import com.platform.system.entity.SysRole;
import io.swagger.annotations.*;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * describe:
 *
 * @author rainly
 * @date 2019/11/29
 * @time 10:35 上午
 */
@RestController
@RequestMapping(value = "test")
public class TestController extends BaseController {

    /**
     * 查询测试 使用注解 ResponseResult
     * @return
     */
    @ApiOperation(value = "查询测试", notes = "查询测试", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "rolename",value = "角色名称",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "roleid",value = "角色id",dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = SysRole.class)
    })
    @GetMapping(value = "query",produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseResult
    public Object query(){
        return 1;
    }

    /**
     * 异常测试
     * @return
     */
    @GetMapping(value = "test",produces = MediaType.APPLICATION_JSON_VALUE)
    public Object test(){
        throw new IllegalArgumentException();
    }

    /**
     * 自定义异常测试
     * @return
     */
    @GetMapping(value = "test2",produces = MediaType.APPLICATION_JSON_VALUE)
    public Object test2(){
        throw new BaseException(ResultCodeEnum.FAILURE);
    }

    @GetMapping(value = "test3",produces = MediaType.APPLICATION_JSON_VALUE)
    public Object test3(){
        String[] strings = new String[3];
        String s = strings[5];
        return null;
    }

    @PostMapping(value = "test4",produces = MediaType.APPLICATION_JSON_VALUE)
    public Object test4(@RequestBody String tttt){
//        String[] strings = new String[3];
//        String s = strings[5];
        return null;
    }



}
